home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2010 May / maximum-cd-2010-05.iso / DiscContents / AutoHotkey104805_Install.exe / Extras / Editors / Syntax / Scripts / Generate PSPad.ahk < prev    next >
Encoding:
Text File  |  2009-09-16  |  3.2 KB  |  124 lines

  1. ;;; ============================================================================
  2. ;;;   FILENAME: Generate PSPad.ahk
  3. ;;; ============================================================================
  4. ;;;   PSPad Syntax Generator Script
  5. ;;; ============================================================================
  6. ;;;   AUTHOR:  Scott Greenberg  
  7. ;;;   COMPANY: SG Technology
  8. ;;;   VERSION: 1.0.0, 02/08/2005 - 02/08/2005
  9. ;;;   WEBSITE: http://gogogadgetscott.info/
  10. ;;;
  11. ;;; ============================================================================
  12. ;;;   NOTE:
  13. ;;;    Derived from Rajat's PSPad Syntax Generator Script
  14. ;;; ============================================================================
  15.  
  16. SetBatchLines, -1     ; Speeds up file operations.
  17. SetWorkingDir, ..\..  ; Set it to the Editors folder.
  18.  
  19. TargetFile = PSPad\AutoHotkey.ini
  20. FileDelete, %TargetFile%
  21.  
  22. FileAppend,
  23. (
  24. ; PSPad keyword syntax file for AutoHotkey
  25. ; Auto generated by GoGoGadgetScott's PSPad Syntax Generator Script
  26.  
  27. [Settings]
  28. Name=AutoHotkey
  29. HTMLGroup=0
  30. FileType=*.ahk
  31. CommentString=;
  32. CComment=1
  33. BasComment=1
  34. SingleQuote=1
  35. DoubleQuote=1
  36. Preprocessors=1
  37. KeyWordChars=-_#
  38. CodeExplorer=ftAHK
  39.  
  40. [KeyWords]
  41.  
  42. ), %TargetFile%
  43.  
  44.  
  45. ;this doesn't require fancy cmd names for human reading,
  46. ;it just requires names to be highlighted. so getting first name only
  47.  
  48. Loop, Read, Syntax\Commands.txt, %TargetFile%
  49. {
  50.     CurrCmd =
  51.     FullCmd = %a_loopreadline%
  52.     
  53.     ;directives don't have first comma but a first space
  54.     ;so whichever is first, take it as end of cmd name
  55.     StringGetPos, cPos, a_loopreadline, `,
  56.     StringGetPos, sPos, a_loopreadline, %A_Space%
  57.     
  58.     IfLess, sPos, %cPos%
  59.         IfGreater, sPos, 0
  60.             StringLeft, CurrCmd, a_loopreadline, %sPos%
  61.     
  62.     IfLess, cPos, %sPos%
  63.         IfGreater, cPos, 0
  64.             StringLeft, CurrCmd, a_loopreadline, %cPos%
  65.  
  66.     IfLess, cPos, %sPos%
  67.         IfLess, cPos, 0
  68.             StringLeft, CurrCmd, a_loopreadline, %sPos%
  69.  
  70.     IfLess, sPos, %cPos%
  71.         IfLess, sPos, 0
  72.             StringLeft, CurrCmd, a_loopreadline, %cPos%
  73.             
  74.     StringReplace, FullCmd, FullCmd, ``n, `n, a
  75.     StringReplace, FullCmd, FullCmd, ``t, `t, a
  76.  
  77.     StringReplace, CurrCmd, CurrCmd, [,, a
  78.     StringReplace, CurrCmd, CurrCmd, %a_space%,, a
  79.     
  80.     ;For a directive that has no parameters
  81.     IfEqual, CurrCmd,
  82.         CurrCmd = %a_loopreadline%
  83.     
  84.     
  85.     ;this check removes duplicates for loop and if
  86.     IfNotEqual, CurrCmd, %LastCmd%
  87.         FileAppend, %CurrCmd%=`n
  88.     
  89.     LastCmd = %CurrCmd%
  90. }
  91.  
  92.  
  93. FileAppend, `n[ReservedWords]`n, %TargetFile%
  94.  
  95. ;Adding keywords including the blank lines and comments
  96. Loop, Read, Syntax\Keywords.txt, %TargetFile%
  97.     FileAppend, %A_LoopReadLine%=`n
  98.  
  99. FileAppend, `n`n, %TargetFile%
  100.  
  101. FileAppend, `n[KeyWords2]`n, %TargetFile%
  102.  
  103. ;same with variables
  104. Loop, Read, Syntax\Variables.txt, %TargetFile%
  105.     FileAppend, %A_LoopReadLine%=`n
  106.  
  107.  
  108. FileAppend, `n[KeyWords3]`n, %TargetFile%
  109.  
  110. ;keys are added with and without {}
  111. Loop, Read, Syntax\Keys.txt, %TargetFile%
  112. {
  113.     FileAppend, %A_LoopReadLine%=`n
  114.     IfEqual, A_LoopReadLine,, Continue
  115.     
  116.     ;comment check
  117.     StringReplace, check, A_LoopReadLine, %A_Space%,, A
  118.     StringReplace, check, check, %A_Tab%,, A
  119.     StringLeft, check, check, 1
  120.     IfEqual, check, `;, Continue
  121.     
  122.     FileAppend, {%A_LoopReadLine%}=`n
  123. }
  124.